const api_port = 8081;
const serve_port = 8080;
const path = require("path");
/**
 * @type {import("@vue/cli-service").ProjectOptions}
 */
const vueConfig = {
  assetsDir: "static",
  outputDir: "../HT.Management.System.Server/src/main/resources/static/ui/",
  publicPath: process.env.ENV == "development" ? "/" : "/ui/",
  productionSourceMap: false,
  devServer: {
    port: serve_port,
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        target: `http://localhost:${api_port}/api`,
        changeOrigin: true,
        pathRewrite: {
          ["^" + process.env.VUE_APP_BASE_API]: ""
        }
      }
    }
  },
  configureWebpack: {
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./src/")
      },
      modules: ["node_modules"]
    }
  },
  css: {
    loaderOptions: {
      postcss: {
        plugins: [
          require("autoprefixer")(),
          require("postcss-plugin-px2rem")({
            rootValue: 54, // 新版本的是这个值  按宽屏设计 对不同设备进行不同的缩放设置
            // mediaQuery: true, //（布尔值）允许在媒体查询中转换px。
            // //exclude: /(node_module)/,
            // minPixelValue: 1 //设置要替换的最小像素值(3px会被转rem)。 默认 0
            viewportWidth: 1920, //根据视觉稿的宽度进行设置
            viewportHeight: 1050,
            unitPrecision: 5,
            viewportUnit: "vw",
            selectorBlackList: [], //忽略转换的css选择器
            minPixelValue: 1,
            mediaQuery: true
          }),
          require("postcss-viewport-units")()
        ]
      }
    }
  }
};

module.exports = vueConfig;
